package in.muton.edushare.grading.panels.studentGrades;

import in.muton.edushare.grading.panels.CourseGradePanel;
import in.muton.edushare.grading.panels.gradeDisplay.CourseView;
import in.muton.edushare.pages.EduShareBasePage;
import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.edushare.processing.objects.UserDataHandler;
import in.muton.edushare.wicket.models.CayenneList;

import org.apache.wicket.markup.html.JavascriptPackageResource;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import com.edushare.common.vo.CourseInstances;
import com.edushare.common.vo.Enrolments;
import com.edushare.common.vo.Users;

public class StudentCourseGradePanel extends EdusharePanel {
	private IModel<Users> userModel = null;

	public StudentCourseGradePanel(String id, IModel<Users> model,
			EduShareBasePage page) {
		super(id, model, page);
		this.userModel = model;
		add(JavascriptPackageResource.getHeaderContribution(
				CourseGradePanel.class, "grade.js"));
		UserDataHandler ud = new UserDataHandler(model);
		CayenneList<CourseInstances> cInst = ud
				.getCourseInstByRole(Enrolments.STUDENT);
		cInst.add(ud.getCourseInstByRole(Enrolments.OBSERVER));

		add(new ListView<IModel<CourseInstances>>("studentGradesLV", cInst
				.getObject()) {
			private static final long serialVersionUID = -1211909701834675073L;
			@Override
			protected void populateItem(ListItem<IModel<CourseInstances>> arg0) {
				arg0.add(new CourseView("studentGrades", userModel, arg0
						.getModelObject()));
			}
		});
	}

	private static final long serialVersionUID = 5582130389649734947L;
}
